package org.lsy.listener;

import lombok.extern.slf4j.Slf4j;
import org.lsy.service.OrderService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author SHIYUAN
 * @version 1.0
 */
@Component
@Slf4j
public class OrderListener {

    @Autowired
    private OrderService orderService;

    @RabbitListener(queues = "q.order.dlx")
    public void service(String message) {
        log.info("接收到消息：{}", message);
        try {
            orderService.cancelOrder(message);
        } catch (Exception e) {
            log.error("没有查到订单，订单号：{}", message);
        }
    }
}
